//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace WorkflowApplicationControls
{
    using System.Windows.Controls;
    using Microsoft.Research.ScientificWorkflow.UIDesigner.WpfComposite;
    using Microsoft.Practices.Unity;
    using System.ComponentModel;

    /// <summary>
    /// The presenter defining the toolbar operations.
    /// </summary>
    public class ToolBarPresenter : INotifyPropertyChanged
    {
        #region Private data

        private IUnityContainer container;

        private bool showSaveAsWfl = true;

        private bool showConnectionOptions = true;

        #endregion Private data

        #region Properties

        /// <summary>
        /// Indicates if the save as wfl button should be visible or not.
        /// </summary>
        public bool ShowSaveAsWorkflowLink
        {
            get
            {
                return this.showSaveAsWfl;
            }
            set
            {
                this.showSaveAsWfl = value;
                if (this.PropertyChanged != null)
                {
                    this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("ShowSaveAsWfl"));
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether show connection options.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if show connection options; otherwise, <c>false</c>.
        /// </value>
        public bool ShowConnectionOptions
        {
            get
            {
                return this.showConnectionOptions;
            }
            set
            {
                this.showConnectionOptions = value;
                if (this.PropertyChanged != null)
                {
                    this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("ShowConnectionOptions"));
                }
            }
        }

        /// <summary>
        /// Gets or sets the content view.
        /// </summary>
        /// <value>The content view.</value>
        public UserControl ContentView { get; set; }

        /// <summary>
        /// Gets or sets the execute command.
        /// </summary>
        /// <value>The execute command.</value>
        public DelegateCommand<object> PlayCommand { get; set; }

        /// <summary>
        /// Gets or sets the pause command.
        /// </summary>
        /// <value>The pause command.</value>
        public DelegateCommand<object> PauseCommand { get; set; }

        /// <summary>
        /// Gets or sets the terminate command.
        /// </summary>
        /// <value>The terminate command.</value>
        public DelegateCommand<object> TerminateCommand { get; set; }

        /// <summary>
        /// Gets or sets the save as WFL command.
        /// </summary>
        /// <value>The save as WFL command.</value>
        public DelegateCommand<object> SaveAsWorkflowLinkCommand { get; set; }

        /// <summary>
        /// Gets or sets the refresh command.
        /// </summary>
        /// <value>The refresh command.</value>
        public DelegateCommand<object> RefreshCommand { get; set; }

        /// <summary>
        /// Gets or sets the exit command.
        /// </summary>
        /// <value>The exit command.</value>
        public DelegateCommand<object> ExitCommand { get; set; }

        /// <summary>
        /// Gets or sets the connection command.
        /// </summary>
        /// <value>The connection command.</value>
        public DelegateCommand<object> SavedConnectionCommand { get; set; }

        /// <summary>
        /// Gets or sets the advanced connection command.
        /// </summary>
        /// <value>The advanced connection command.</value>
        public DelegateCommand<object> AdvancedConnectionCommand { get; set; }

        /// <summary>
        /// Gets or sets the about command.
        /// </summary>
        public DelegateCommand<object> AboutCommand { get; set; }

        #endregion Properties

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="ToolbarPresenter"/> class.
        /// </summary>
        /// <param name="toolBar">The tool bar.</param>
        /// <param name="container">The container.</param>
        public ToolBarPresenter(ToolBarControl toolBar, IUnityContainer container)
        {
            this.container = container;
            this.ContentView = toolBar;
            this.ContentView.DataContext = this;
        }

        #endregion Constructor

        #region INotifyPropertyChanged Members

        /// <summary>
        /// Fired to indicate a property change event.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
